#include "EventSet.h"
EventSet::EventSet(void)
{
}
EventSet::~EventSet(void)
{
}
void EventSet::addEvent(const std::string& name,SubscriberSlot& subscriber)
{
	if (hasEvent(name))
	{
		return;
	}
	mSlots.insert(std::pair<std::string,SubscriberSlot>(name,subscriber));
}
void EventSet::removeEvent(const std::string& name)
{
	mSlots.erase(mSlots.find(name));
}
void EventSet::removeAllEvents(void)
{
	mSlots.clear();
}
bool EventSet::hasEvent(const std::string& name)
{
	std::map<std::string,SubscriberSlot>::iterator it;
	it = mSlots.find(name);
	if (it == mSlots.end())
	{
		return false;
	}
	return true;
}
void EventSet::dispatchEvent(const std::string& name, void* dispatcher, EventArgs& args)
{
	std::map<std::string,SubscriberSlot>::iterator it;
	it = mSlots.find(name);
	if (it == mSlots.end())
	{
		return;
	}
	SubscriberSlot slot = it->second;
	slot(dispatcher,args);
}